Q Where does the Standard File Package get its icons?
A The Standard File Package uses PBDTGetIcon to get icon data from the desktop database. You can observe this by entering the following command in MacsBug to place a break point on the call:
atb _HFSDispatch d0=23
The sample code calls PBDTGetIcon.
static OSErr GetIconHandle(Handle h) { OSErr err; short DTrefNum; Rect srcRect; Str255 volName = "\pMacintosh HD"; short i; IcnInfo ic; pb.ioCompletion = NULL; pb.ioVRefNum = 0; pb.ioNamePtr = volName; err= PBDTGetPath(&pb); if( err ) return err; DTrefNum = pb.ioDTRefNum; HLock(h); b.ioCompletion = NULL; b.ioDTRefNum = DTrefNum; b.ioTagInfo = 0L; b.ioDTBuffer = *h; b.ioDTReqCount = kLarge8BitIconSize; /* ask for the largest */ b.ioFileCreator = 'ttxt'; /* hard wiring these values */ b.ioFileType = 'APPL'; err = PBDTGetIcon(&b,0); HUnlock(h); return(err); }
Disclaimer: This code has not been fully tested, so it is provided on an as- is basis only. You are responsible for all testing, if you decide to include it in any of your own code.